using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;
namespace IceAge
{
    public partial class ChangePassword : Form
    {
        public ChangePassword()
        {
            InitializeComponent();
        }

        private void btnChange_Click(object sender, EventArgs e)
        {
            if (txtPassword.Text.Trim() == string.Empty)
            {
                MessageBox.Show("Mat khau hien tai khong duoc phep de trong!",
                    this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtPassword.Focus();
                return;
            }

            if (txtNewPassword.Text.Trim() == string.Empty)
            {
                MessageBox.Show("Mat khau moi khong duoc phep de trong!",
                    this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtNewPassword.Focus();
                return;
            }

            if (txtConfirm.Text.Trim() != txtNewPassword.Text.Trim())
            {
                MessageBox.Show("Mat khau moi va xac nhan lai phai trung nhau!",
                    this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtConfirm.Focus();
                return;
            }

            string err = CommonLibrary.GetStringFromProcedure("p_upd_ChangePassword", "'" +
                CommonLibrary.USER_NAME+ "','" + 
                CommonLibrary.MD5CryptPassword( txtPassword.Text.Trim()) + "','" + 
                CommonLibrary.MD5CryptPassword(txtNewPassword.Text.Trim()) + "'").ToString();
            if (err == "0100")
                MessageBox.Show("Mat khau da duoc doi thanh cong!",
                    this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            else
                MessageBox.Show("Mat khau hien thoi khong dung!",
                    this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            txtConfirm.ResetText();
            txtNewPassword.ResetText();
            txtPassword.ResetText();
        }
    }
}